< previous page page_551 next page >

Page 551
e10a6a0a59f035e870d90cca05b85fce.gif
     ' IsAbove tests were inconclusive, some points
     ' in one polygon are on the "bad" side of the
     ' other. In that case there is an overlap.

    ' See if this polygon is inside the other.
    GetTransformedPoint 1, xi1, yi1, zi1
    If target.PointInside(xi1, yi1) Then
        Obscures = True
        Exit Function
    End If

    ' See if the other polygon is inside this one.
    target.GetTransformedPoint 1, xi1, yi1, zi1
    If PointInside(xi1, yi1) Then 
        Obscures = True
        Exit Function
    End If

    Obscures = False
End Function
The FindCrossing Function
Function Obscures uses the FindCrossing function to see where two polygon edges cross each other. This routine takes as parameters the endpoints of two line segments. It determines if the segments cross over each other, and if they do, it determines the Z coordinate values of the segments where they cross.
The function uses parametric representations for the line segments. If a line segment connects the points (ax1, ay1) and (ax2, ay2), you can represent the X and Y coordinates of the points along the segment using a variable t1, like this:
e10a6a0a59f035e870d90cca05b85fce.gif
X(t1) = ax1+ t1 * (ax2 - ax1)
Y(t1) = ay1 + t1 * (ay2 - ay1)
To generate the points on the segment, you vary the value of t1 between 0.0 and 1.0. You can create similar equations using a variable t2 to represent the second line segment connecting the points (bx1, by1) and (bx2, by2).
Where the segments intersect, the values of the X and Y coordinates of both segments are the same. The equations give:
e10a6a0a59f035e870d90cca05b85fce.gif
ax1 + t1 * (ax2 - ax1) = bx1 + t2 * (bx2 - bx1)
ay1 + t1 * (ay2 - ay1) = by1 + t2 * (by2 - by1)
These two equations contain two unknown values, t1 and t2. The FindCrossing function solves the equations to find these values. If both values are between 0.0 and 1.0, the segments cross each other. FindCrossing then uses the values of t1 and t2 to calculate the Z coordinates of each segment where they cross.

 
< previous page page_551 next page >